<?php

namespace IDock\Insurance\YAIC\Request;

use IDock\Insurance\YAIC\Response\UnderwritingResponse;
use IDock\Insurance\YAIC\YAICEnums;
use IDock\Visitor\Premium\PremiumInquiryVisitor;

class UnderwritingRequest extends AllYAICRequest
{
    protected $route = '';

    protected $response = UnderwritingResponse::class;

    protected $urlTip = '提交核保';

    /*** @var  PremiumInquiryVisitor $visitor */
    protected $visitor;

    public $transCode = 'C3';

    public $notifyUrl = '';

    public function generate(): array
    {
        $arr = [
            'callbackUrl' => $this->notifyUrl,
            'underwNotifyUrl' => $this->notifyUrl,
            'proposalNoBI' => $this->visitor->getExtInfoVisitor()->argc['proposalNoBI'] ?? '',
            'proposalNoCI' => $this->visitor->getExtInfoVisitor()->argc['proposalNoCI'] ?? '',
            'dispatch' => [
                'shippingMethod' => '3',
            ],
            'extendInfo' => [
                'ExtendInfoDTO' => [
//                ['key' => 'carColor', 'value' => $this->visitor->vehicleVisitor->vehicleColor],
                    ['key' => 'carColor', 'value' => '010'],
                ]
            ]
        ];
        if ($this->visitor->ciStartData) {
            $arr['quotationNoCI'] = $this->visitor->getUnderwritingVisitor()->ciInquiryNo;
        }
        if ($this->visitor->biStartData) {
            $arr['quotationNoBI'] = $this->visitor->getUnderwritingVisitor()->biInquiryNo;
        }
        if (!empty($this->visitor->getExtInfoVisitor()->argc['uploadImageNos'])) {
            foreach ($this->visitor->getExtInfoVisitor()->argc['uploadImageNos'] as $val) {
                $arr['extendInfo']['ExtendInfoDTO'][] = ['key' => 'imageNumber', 'value' => $val];
            }
        }
        return $arr;
    }
}
